package com.isunland.managesystem.ui;

import android.os.Bundle;
import android.support.v4.app.Fragment;
import com.isunland.managesystem.R;
import com.isunland.managesystem.base.BasePagerActivity;

public class CustomerChoosePagerActivity extends BasePagerActivity {
  protected static final String EXTRA_TYPE =
      "com.isunland.managesystem.ui.CustomerChoosePagerActivity.EXTRA_TYPE";
  private String type = "";
  private EnterpriseListFragment mfragment;

  private int[] mtitle;

  @Override protected void onCreate(Bundle arg0) {
    type = getIntent().getStringExtra(EXTRA_TYPE);

    super.onCreate(arg0);
  }

  //入库：供应商和部门  //出库：客户和部门
  @Override protected Fragment createFragmentOne() {
    //入库：供应商
    if ("in".equals(type)) {
      mfragment = EnterpriseListFragment.newInstance(EnterpriseListFragment.VALUE_SUPPLIER);
    }
    //出库：客户
    else if ("out".equals(type)) {
      mfragment = EnterpriseListFragment.newInstance(EnterpriseListFragment.VALUE_CUSTOMER);
    }
    return mfragment;
  }

  //部门
  @Override protected Fragment createFragmentTwo() {

    return new DeptListFragment();
  }

  @Override protected int[] createTitle() {
    //入库：供应商和部门  //出库：客户和部门
    if ("in".equals(type)) {
      int[] title = { R.string.supplier, R.string.dept };
      mtitle = title;
    } else if ("out".equals(type)) {
      int[] title = { R.string.customer, R.string.dept };
      mtitle = title;
    }
    return mtitle;
  }
}
